import axios from 'axios';
console.log('当前环境变量：' + process.env.NODE_ENV);
console.log('当前环境路径：' + process.env.VUE_APP_URL);
const service = axios.create({
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    // baseURL: process.env.VUE_APP_URL
    timeout: 10000
});
service.interceptors.request.use(
    config => {
        // console.info('config', config)
        return config;
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);
service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return Promise.resolve(response.data);
        } else {
            Promise.reject(response.data);
        }
    },
    error => {
        if (error.response) {
            switch (error.response.status) {
                case 401:
                    setTimeout(()=>{
                    },2200)         
                    break;
            }
            return
        }
        return Promise.reject(error);
    }
);
export default service;
